#include <gtest/gtest.h>
//use 
static std::error_code func(){
  return std::make_error_code(std::errc::permission_denied);
}

TEST(StdErrorCodeTest, useIt){
    std::error_code ec = func();
    ASSERT_TRUE(ec == std::errc::permission_denied);
    ASSERT_TRUE(ec != std::errc::file_exists);
}





//customize impl 
#include "helper/sqlite/Error.h"
static std::error_code queryFailed(int i){
  switch(i){
    case 1 :
      return std::make_error_code(std::errc::invalid_argument);
    case 2:
      return std::error_code(helper::sqlite::error::done);
    case 3:
      return std::error_code(helper::sqlite::error::interrupt);
    case 4:
      return std::error_code(helper::sqlite::error::ok);
    default:
      return std::error_code(); // true -> valid-error-code; false -> 0 : no error
  }
}

TEST(SqliteErrorCodeTest, test){
  {
    auto && e = queryFailed(0);
    ASSERT_TRUE(!e); //not an error
  }

  {
    auto && e = queryFailed(1);
    ASSERT_TRUE(e == std::errc::invalid_argument);
  }
  {
    auto && e = queryFailed(2);
    ASSERT_TRUE(e == helper::sqlite::error::done);
  }
  {
    auto && e = queryFailed(3);
    ASSERT_TRUE(e == std::errc::interrupted);
  }
  {
    auto && e = queryFailed(4);
    ASSERT_TRUE(e == std::error_code());
    ASSERT_TRUE(!e);
  }
}
